﻿using ADSTS_SERVER.Models;
using Furion.UnifyResult;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;

namespace ADSTS_SERVER.Controllers
{
    [DynamicApiController]
    public class InitController
    {
        private readonly ILogger<InitController> logger;
        private readonly ISqlSugarClient db; // 核心对象：拥有完整的SqlSugar全部功能
        public InitController(ISqlSugarClient db)
        {
            this.db = db;
            this.logger = logger;
        }

        /// <summary>
        /// 测试接口
        /// </summary>
        /// <returns></returns>
        public async Task<IActionResult> Test()
        {
            db.CodeFirst.InitTables(typeof(RoadMap));
            return new JsonResult(new RESTfulResult<object>
            {
                StatusCode = 200,
                Succeeded = true,
                Data = db.DbMaintenance.GetTableInfoList(false),
                Errors = null,
                Extras = UnifyContext.Take(),
                Timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
            });
        }
    }
}
